<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户添加')" />
</head>
<body>
	<section class="content">
		<form class="form-horizontal" id="userForm">
			<div class="form-group">
				<label class="col-sm-3 control-label">用户名 <span
					style="color: red">*</span>:
				</label>
				<div class="col-sm-8">
					<input name="username" class="form-control" placeholder="输入用户名" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">密码 <span
					style="color: red">*</span>:
				</label>
				<div class="col-sm-8">
					<input name="password" type="password" class="form-control" required placeholder="输入密码">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">确认密码 <span
					style="color: red">*</span>:
				</label>
				<div class="col-sm-8">
					<input name="confirmPassword" type="password" class="form-control" required placeholder="输入确认密码">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">邮箱 :</label>
				<div class="col-sm-8">
					<input name="email" class="form-control" placeholder="输入邮箱" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">电话 :</label>

				<div class="col-sm-8">
					<input name="phone" class="form-control" placeholder="输入电话" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">性别 :</label>
				<div class="col-sm-8">
					<select name="sex" class="form-control" required>
						<option value="0">请选择</option>
						<option value="1">男</option>
						<option value="2">女</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">年龄 :</label>
				<div class="col-sm-8">
					<input name="age" class="form-control" placeholder="输入年龄" required>
				</div>
			</div>
		</form>
	</section>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		function submitHandler() {
			if ($("#userForm").validate().form()) {
				$.common.postAjax(ctx + "user/doAdd", $("#userForm").serialize(),
					function(data) {
						if (data.code == 0) {
							parent.layer.closeAll('iframe'); // 关闭当前frame
							var topWindow = $(window.parent.document);
							var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
							var topWindow = $('.J_iframe[data-id="' + currentId + '"]', topWindow)[0];
							if (!$.common.isEmpty(topWindow) && !$.common.isEmpty(currentId)) {
								var $contentWindow = topWindow.contentWindow;
								$contentWindow.$(".layui-layer-padding").removeAttr("style");
								$contentWindow.$.table.refreshTable();
								$contentWindow.toastr.success(data.msg);
							} else {
								toastr.error(data.msg);
							}
						} else {
							toastr.error(data.msg);
						}
					}
				)
			}
		}
	</script>
</body>
</html>